module.exports = {
  // 每天的零点五分执行任务
  schedule: {
    cron: '0 5 0 * * *',
    type: 'worker',
  },
  async task(ctx) {
    return
    // 56b4333f511619be0fbaa6475d82395d
    const url = 'https://webapi.amap.com/maps?v=2.0&key=e79b404f5b25a89704095520699fc98f&plugin=Map3D,AMap.PolyEditor'; // 替换为你要调用的实际 URL
    // const totalCalls = 50000;
    const totalCalls = 10;
    const callsPerSecond = 10;
    let currentCalls = 0;

    const callUrl = async () => {
      if (currentCalls >= totalCalls) {
        return;
      }
      try {
        await ctx.curl(url);
        currentCalls++;
      } catch (error) {}
    };

    const intervalId = setInterval(async () => {
      for (let i = 0; i < callsPerSecond; i++) {
        await callUrl();
      }
      if (currentCalls >= totalCalls) {
        clearInterval(intervalId);
        ctx.logger.info('All calls completed');
      }
    }, 1000);
  },
};